import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'dart:ui' as ui;

import 'package:flutter_svg/svg.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Text Width Example'),
        ),
        body: MyTextWidget(),
      ),
    );
  }
}

class MyTextWidget extends StatelessWidget {

  Future<ui.Image> _loadSvgImage(String path) async {
    var data = await rootBundle.load(path);
    var codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: 51, targetHeight: 10);
    var info = await codec.getNextFrame();
    return info.image;
  }
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Container(
            width: 100,
            height: 100,
            child: FutureBuilder(
              future: _loadSvgImage("assets/fuxiang.png"),
                builder: (context, AsyncSnapshot<ui.Image> image) {
                  return (image.hasData)
                      ? ShaderMask(
                    child: Image.asset("assets/gear.png",width: 100,height: 100,),
                    shaderCallback: (bounds) {
                      return RadialGradient(
                        center: Alignment.topLeft,
                        radius: 1.0,
                        colors: [Colors.yellow,Colors.orange],
                        tileMode: TileMode.mirror,
                      ).createShader(bounds);
                    },
                    blendMode: BlendMode.srcIn,
                  )
                      : Container();
                }
            ),
          ),
          Container(
            width: 100,
            height: 100,
            child: ShaderMask(
              shaderCallback: (Rect bounds) {
                return RadialGradient(
                  center: Alignment.topLeft,
                  radius: 1.0,
                  colors: [Colors.yellow,Colors.orange],
                  tileMode: TileMode.mirror,
                ).createShader(bounds);
              },
              child: const Text(
                'I’m burning the memories',
                style: TextStyle(color: Colors.white),
              ),
            ),
          ),
          Image.asset("assets/fuxiang.png",width: 100,height: 100,),
        ],
      ),
    );
  }

}
